/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.telsoft.hms.lib.security.session;

/**
 * @author VIETPH
 * Ngày tạo:
 * 12/09/2014
 */
public class SessionCount {

    private int count;

    public SessionCount() {
        this.count = 1;
    }

    public synchronized int howMany() {
        return count;
    }

    private synchronized void subtract(int count) {
        if (this.count - count < 0) {
            this.count = 0;
        } else {
            this.count -= count;
        }
    }

    private synchronized void add(int count) {
        this.count += count;
    }

    public void increase() {
        add(1);
    }

    public void decrease() {
        subtract(1);
    }
}
